#ifndef PROTOCOL_H
#define PROTOCOL_H
#include <QString>

using uint = unsigned int;

static const char* REGIST_OK = "注册成功";
static const char* REGIST_FAILED = "注册失败";
static const char* LOGIN_OK = "登陆成功";
static const char* LOGIN_FAILED = "登陆失败";
static const char* NO_THIS_PEOPLE = "没有这个用户";
static const char* PEOPLE_ONLINE = "此用户在线";
static const char* PEOPLE_NOT_ONLINE = "此用户不在线";

static const char* NAME_IS_NULL = "参数的名字为空";
static const char* ALREADY_FRIEND = "已经是好友";
static const char* DEL_FRIEND_OK = "删除好友成功";
/*
handle_add_friend返回值:
参数的名字为空: -1;
已经是好友: 0;
对方在线: 1;
对方不在线: 2;
对方不存在: 3
*/

//文件操作---------------------------------------------
static const char* CREATE_DIR_FAILED = "创建文件夹失败";
static const char* CREATE_DIR_OK = "创建文件夹成功";
static const char* DIR_ALREADY_EXISTS = "文件夹已经存在";

static const char* DEL_FILE_FAILED_NOT_EXISTS = "删除文件失败(文件不存在)";
static const char* DEL_FILE_FAILED = "删除文件失败";
static const char* DEL_FILE_OK = "删除成功";
static const char* FLUSH_FILE_OK = "刷新文件成功";

static const char* RENAME_FILE_OK = "重命名文件成功";
static const char* RENAME_FILE_FAILED = "重命名失败";
static const char* RENAME_FILE_FAILED_NO_EXISTS = "重命名成功(文件不存在)";
static const char* NEW_NAME_FILE_FAILED_ALREADY_EXISTS = "新的文件名已经存在";

static const char* ENTER_DIR_FAILED = "进入文件夹失败";

static const char* UPLOAD_FILE_OK = "上传文件成功";
static const char* UPLOAD_FILE_FAIL = "上传文件失败";

static const char* SHARE_FILE_OK = "共享文件成功";

static const char* MOVE_FILE_OK = "移动文件成功";
static const char* MOVE_FILE_FAIL = "移动文件失败";


// #define REGIST_OK "注册成功"
// #define REGIST_FAILED "注册失败"

struct FileInfo {
    char file_name[32];
    int file_type;
};

struct PDU{
    uint uiPDULen;  //总的协议数据单元大小
    uint uiMsgType;
    char caData[64];
    uint uiMsgLen;  //实际消息长度
    int caMsg[];    //实际消息

    void printPDU();
};

enum ENUM_MSG_TYPE {
    ENUM_MSG_TYPE_MIN = 0,
    ENUM_MSG_TYPE_REGIST_REQUEST,   //注册请求
    ENUM_MSG_TYPE_REGIST_RESPOND,   //注册回复
    ENUM_MSG_TYPE_LOGIN_REQUEST,    //登陆请求
    ENUM_MSG_TYPE_LOGIN_RESPOND,    //登陆回复
    ENUM_MSG_TYPE_SHOW_ONLINE_REQUEST,
    ENUM_MSG_TYPE_SHOW_ONLINE_RESPOND,
    ENUM_MSG_TYPE_SEARCH_REQUEST,
    ENUM_MSG_TYPE_SEARCH_RESPOND,
    ENUM_MSG_TYPE_ADD_FRIEND_REQUEST,
    ENUM_MSG_TYPE_ADD_FRIEND_RESPOND,
    ENUM_MSG_TYPE_ADD_FRIEND_AGREE,
    ENUM_MSG_TYPE_ADD_FRIEND_REFUSE,
    ENUM_MSG_TYPE_FLUSH_FRIEND_REQUEST,
    ENUM_MSG_TYPE_FLUSH_FRIEND_RESPOND,
    ENUM_MSG_TYPE_DEL_FRIEND_REQUEST,
    ENUM_MSG_TYPE_DEL_FRIEND_RESPOND,

    ENUM_MSG_TYPE_SEND_MSG_REQUEST,
    ENUM_MSG_TYPE_SEND_MSG_RESPOND,

    ENUM_MSG_TYPE_GROUP_CHAT_REQUEST,
    ENUM_MSG_TYPE_GROUP_CHAT_RESPOND,

    //文件操作---------------------------------------------
    ENUM_MSG_TYPE_CREATE_DIR_REQUEST,
    ENUM_MSG_TYPE_CREATE_DIR_RESPOND,

    ENUM_MSG_TYPE_FLUSH_FILE_REQUEST,
    ENUM_MSG_TYPE_FLUSH_FILE_RESPOND,

    ENUM_MSG_TYPE_DEL_FILE_REQUEST,
    ENUM_MSG_TYPE_DEL_FILE_RESPOND,

    ENUM_MSG_TYPE_RENAME_FILE_REQUEST,
    ENUM_MSG_TYPE_RENAME_FILE_RESPOND,

    ENUM_MSG_TYPE_ENTER_FOLDER_REQUEST,
    ENUM_MSG_TYPE_ENTER_FOLDER_RESPOND,

    ENUM_MSG_TYPE_GO_BACK_DIR_REQUEST,
    ENUM_MSG_TYPE_GO_BACK_DIR_RESPOND,

    ENUM_MSG_TYPE_UPLOAD_FILE_REQUEST,
    ENUM_MSG_TYPE_UPLOAD_FILE_RESPOND,

    ENUM_MSG_TYPE_DOWNLOAD_FILE_REQUEST,
    ENUM_MSG_TYPE_DOWNLOAD_FILE_RESPOND,

    ENUM_MSG_TYPE_SHARE_FILE_REQUEST,
    ENUM_MSG_TYPE_SHARE_FILE_RESPOND,
    ENUM_MSG_TYPE_SHARE_FILE_NOTE,
    ENUM_MSG_TYPE_SHARE_FILE_NOTE_RESPOND,

    ENUM_MSG_TYPE_MOVE_FILE_REQUEST,
    ENUM_MSG_TYPE_MOVE_FILE_RESPOND,

    ENUM_MSG_TYPE_MAX = 0x00ffffff

};

PDU* makePDU(uint uiMsgLen);

#endif // PROTOCOL_H
